package com.jsftoolkit.gen.builder;

import com.jsftoolkit.gen.info.ComponentInfo;
import com.jsftoolkit.gen.info.ConfigInfo;

/**
 * Utility class for filling in an instance of {@link ConfigInfo}.
 * 
 * @author noah
 * 
 */
public class ConfigBuilder {
	private final ConfigInfo info;

	/**
	 * 
	 * @param info
	 *            the {@link ConfigInfo} instance to operate on.
	 */
	public ConfigBuilder(ConfigInfo info) {
		super();
		this.info = info;
	}

	/**
	 * This method is usually only called by {@link ComponentBuilder}.
	 * 
	 * @param component
	 *            the parent {@link ComponentInfo} instance.
	 * @return this
	 */
	public ConfigBuilder forComponent(ComponentInfo component) {
		info.setComponent(component);
		return this;
	}

	/**
	 * 
	 * @param tagName
	 *            the tag name to register
	 * @return this
	 */
	public ConfigBuilder tagNamed(String tagName) {
		info.setTagName(tagName);
		return this;
	}

	/**
	 * Specifies the namespace for .taglib.xml and .tld files.
	 * 
	 * @param namespace
	 *            the namespace
	 * @return this
	 */
	public ConfigBuilder in(String namespace) {
		info.setNamespace(namespace);
		return this;
	}

	/**
	 * Specifies the path to faces-config.xml
	 * 
	 * @param facesConfig
	 *            the path to the file
	 * @return this
	 */
	public ConfigBuilder facesConfig(String facesConfig) {
		info.setFacesConfig(facesConfig);
		return this;
	}

	/**
	 * Specifies the path to the .taglib.xml file
	 * 
	 * @param taglibXml
	 * @return this
	 */
	public ConfigBuilder taglib(String taglibXml) {
		info.setTaglibXml(taglibXml);
		return this;
	}

	/**
	 * Specifies the path to the .tld file.
	 * 
	 * @param tldFile
	 * @return this
	 */
	public ConfigBuilder tld(String tldFile) {
		info.setTldFile(tldFile);
		return this;
	}

	/**
	 * Specifies the short-name for the TLD.
	 * 
	 * @param libraryShortName
	 * @return this
	 */
	public ConfigBuilder andShortName(String libraryShortName) {
		info.setLibraryShortName(libraryShortName);
		return this;
	}

	/**
	 * Specifies the class to register in config files.
	 * 
	 * @param componentClass
	 *            the canonical name of the class to register
	 * @return this
	 */
	public ConfigBuilder registering(String componentClass) {
		info.setRegisterClass(componentClass);
		return this;
	}

	/**
	 * Specifies the renderer to register.
	 * 
	 * @param rendererClass
	 *            the canonical name of the renderer to register
	 * @return this
	 */
	public ConfigBuilder registeringRenderer(String rendererClass) {
		info.setRegisterRenderer(rendererClass);
		return this;
	}
}
